package com.example.zq.player.linked_database_interface.Adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.example.zq.player.R;
import com.example.zq.player.linked_database_interface.domain.ShoppingPager;

import java.util.List;

public class ShoppingPagerAdapter extends RecyclerView.Adapter<ShoppingPagerAdapter.ViewHolder> {

    private List<ShoppingPager> mShoppingPagerList;
    private Context context;


    public class ViewHolder extends RecyclerView.ViewHolder{
        ImageView iv_shopping_pager_picture;
        TextView tv_shopping_pager_describe;
        TextView tv_shopping_pager_price;


        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            iv_shopping_pager_picture=(ImageView)itemView.findViewById(R.id.iv_shopping_pager_picture);
            tv_shopping_pager_describe=(TextView)itemView.findViewById(R.id.tv_shopping_pager_describe);
            tv_shopping_pager_price=(TextView)itemView.findViewById(R.id.tv_shopping_pager_price);

        }

    }



    public ShoppingPagerAdapter(List<ShoppingPager> ShoppingPager){
        mShoppingPagerList=ShoppingPager;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        context=parent.getContext();
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.shopping_pager_item,parent,false);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    private void setItems() {
        View itemView=LayoutInflater.from(context).inflate(R.layout.home_items,null);
        RadioGroup viewGroup=itemView.findViewById(R.id.rb_home);


    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {


            ShoppingPager shoppingPager = mShoppingPagerList.get(position);
            holder.iv_shopping_pager_picture.setImageResource(shoppingPager.getImage());
            holder.tv_shopping_pager_describe.setText(shoppingPager.getDescribe());
            holder.tv_shopping_pager_price.setText(shoppingPager.getPrice() + "");

    }

    @Override
    public int getItemCount() {
        return mShoppingPagerList.size();
    }
}
